package per.dg.keepalive.onepixel

import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Gravity
import android.view.Window
import android.view.WindowManager
import per.dg.keepalive.R

class OnePixelActivity : AppCompatActivity() {

    companion object{
        fun actionToOnePixelActivity(pContext : Context) {
            var intent : Intent = Intent(pContext, OnePixelActivity::class.java)
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            pContext.startActivity(intent);
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_one_pixel)

        var window : Window  = getWindow();
        //放在左上角
        window.setGravity(Gravity.START)
        var attributes : WindowManager.LayoutParams  = window.getAttributes();
        //宽高设计为1个像素
        attributes.width = 1;
        attributes.height = 1;
        //起始坐标
        attributes.x = 0;
        attributes.y = 0;
        window.setAttributes(attributes);

        ScreenManager.getInstance(this).setActivity(this)
    }
}